/*******************************************************************************
*  file    : windvidget.hpp
*  created : 11.07.2014
*  author  : Slyshyk Oleksiy (alexSlyshyk@gmail.com)
*******************************************************************************/

#ifndef WINDVIDGET_HPP
#define WINDVIDGET_HPP

#include <QWidget>
#include <QSharedPointer>
#include <QPointer>

#include <qwt_plot.h>
#ifndef Q_MOC_RUN
#include <boost/circular_buffer.hpp>
#endif

class QwtPlotCurve;
class QwtChartZoom;
class Solutions;

class QwtLegend;


typedef QSharedPointer<QwtPlotCurve> PlotCurvePtr;

namespace Ui {
class WindWidget;
}

class WindWidget : public QWidget
{
    Q_OBJECT

public:
    explicit WindWidget(QWidget *parent = 0);
    ~WindWidget();
    void   setResponceTime(double t_l, double t_r);
    double responceTimeL() const;
    double responceTimeR() const;
    double temperature() const;
    void   setTemperature(double);

    QString path() const;
    void setSolutions(Solutions* sln);
protected:
    void changeEvent(QEvent *e);
signals:
    void pathChanged(const QString& path) ;
    void responceTimeChanged();
    void temperatureChanged(double);
private slots:
    void openDir();
    void updateWindSpeedPlot();
    void showCurve(const QVariant &itemInfo, bool on, int index = 0);
public slots:
    void setPath(const QString& path);
    void setWindSpeed(qint64 t,double s);
private:
    Ui::WindWidget *ui;

    QwtPlot* plot_;
    QMap<QString,PlotCurvePtr> curves_;
    QwtChartZoom* zoom_;
    QwtLegend* legend_;

    boost::circular_buffer<std::pair<qint64,double>> wind_points_;

    QPointer<Solutions> solutions_;
};

#endif // WINDVIDGET_HPP
